import axios from 'axios';
import {Form, Input, Button, Checkbox, Modal} from 'antd';

const API_BASE_URL = 'http://localhost:38080';  // 请替换为你的实际后端地址

export const postRequest = async (endpoint, data) => {
    try {
        const response = await axios.post(`${API_BASE_URL}/${endpoint}`, data);

        if(response.data.error !== undefined ){
            // 处理注册失败的逻辑
            Modal.error({
                title: 'Post Failed',
                content: response.data.error,
            });
        }


        return response.data;  // 返回响应数据
    } catch (error) {
        throw error.response.data;  // 抛出错误信息
    }
};